<?php
require_once 'glob.php';
$page=$_REQUEST['page'];

switch ($_REQUEST['action']) {
	case 'list':
		get_list('sn_members', array(id,name,membertype,mail,tel,integral),'memberlist','member_list.htm','fypage',$page,'where isdel = "N"','?action=list&',18);
		break;
	case 'add':
		$xueniao->assign('member_type',get_membertype());
		$xueniao->assign('citylist',get_citylist());
		
		$xueniao->display('member_info.htm');
		break;
	case 'edit':
		if($_REQUEST['id']=="" || $_REQUEST['id']==null)
		{
			sys_msg('未指定用户,无法修改', 1);
			exit();
		}else {
			$fm_id=$_REQUEST['id'];
		}
		$xueniao->assign('member_type',get_membertype());
		$xueniao->assign('citylist',get_citylist());
		
		get_info('sn_members',array(id,name,membertype,mail,tel,integral), 'memberinfo', 'member_info.htm','id = '.$fm_id);
		break;
	case 'insert':
		if($_REQUEST['fm_name']!=="")
		{
			if (eqdata('sn_members', 'name', $_REQUEST['fm_name'])==true) {
				sys_msg('添加失败，会员名称不能重复',1);
			}
			$post=array(
			name=>$_REQUEST['fm_name'],
			password=>md5($_REQUEST['fm_password']),
			mail=>$_REQUEST['fm_mail'],
			membertype=>$_REQUEST['fm_membertype'],
			tel=>$_REQUEST['fm_tel'],
			city=>$_REQUEST['fm_city'],
			integral=>$_REQUEST['fm_integral']
			);
			$res=$db->insert('sn_members',$post);
			if($res==true){
				sys_msg('会员添加成功',0);
			}
		}else {
			sys_msg('添加失败，会员名称不能为空',0);
		}
		break;
	case 'update':
		if($_REQUEST['fm_id']=="" || $_REQUEST['fm_id']==null)
		{
			sys_msg('未指定用户,无法修改', 1);
			exit();
		}else {
			$fm_id=$_REQUEST['fm_id'];
		}

		$post=array(
		id=>$fm_id,
		password=>md5($_REQUEST['fm_password']),
		mail=>$_REQUEST['fm_mail'],
		membertype=>$_REQUEST['fm_membertype'],
		tel=>$_REQUEST['fm_tel'],
		city=>$_REQUEST['fm_city'],
		integral=>$_REQUEST['fm_integral']
		);
		if($_REQUEST["fm_password"]!="" || $_REQUEST["fm_password"]!=null)
		{
			$post['password']=md5($_REQUEST['fm_password']);
		}

		$res=$db->update('sn_members',$post,id);

		if($res==true){
			sys_msg('资料修改成功！',0);
		}

		break;

	default:
		get_list('sn_members', array(id,name,membertype,mail,tel,integral),'memberlist','member_list.htm','fypage',$page,'where isdel = "N"','?action=list&');
		break;
}
?>